-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api support for sync job cancellation. #2717
base: master
Are you sure you want to change the base?
Conversation
Screen.Recording.2024-11-11.at.12.24.05.PM.movScreen.Recording.2024-11-11.at.2.23.30.PM.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to do this is to accept ExistingWorkPolicy
in sync apis. Instead of ExistingWorkPolicy.KEEP
if application provides ExistingWorkPolicy.REPLACE
, workmanager library will cancel the current one and add new one with the same name.
Why not the above approach ?
@@ -42,12 +42,14 @@ import com.google.android.fhir.sync.CurrentSyncJobStatus.Succeeded | |||
import com.google.gson.Gson | |||
import com.google.gson.GsonBuilder | |||
import java.time.OffsetDateTime | |||
import java.util.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls don't use wildcards
@PublishedApi | ||
internal suspend fun storeWorkId(uuid: UUID, workIdKey: String) { | ||
dataStore.edit { preferences -> | ||
preferences[stringPreferencesKey("$workIdKey-key")] = uuid.toString() | ||
} | ||
} | ||
|
||
/** Fetches the stored UUID from DataStore. */ | ||
@PublishedApi | ||
internal suspend fun fetchWorkId(workIdKey: String): UUID? { | ||
val preferences = dataStore.data.first() | ||
return preferences[stringPreferencesKey("$workIdKey-key")]?.let { UUID.fromString(it) } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be some locking mechanism here?
What if both apis are triggered together for the same workIdKey ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific use case which is tightly coupled with these api?
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #2695
Description
Clear and concise code change description.
Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
Type
Choose one: Feature
Screenshots (if applicable)
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project../gradlew check
and./gradlew connectedCheck
to test my changes locally.